import { useState } from "react";
import { Button } from "antd"
import {FileTextOutlined} from '@ant-design/icons'
import SelectAction from '../../../../../common/components/SelectAction';
import EditColumns from './EditColumns';
import IconFont from '@/components/IconFont';
import BasicSet from '../../../Actions/common/BasicSet';

const options = [
	{
		label: '平台付款时间正序',
		value: 1,
		field: {
			sortBy: 'ecPayTime',
			sortType: true
		}
	},
	{
		label: '平台付款时间倒序',
		value: 2,
		field: {
			sortBy: 'ecPayTime',
			sortType: false
		}
	},
	{
		label: '最晚发货时间，从早到晚',
		value: 3,
		field: {
			sortBy: 'ecLastDeliveryTime',
			sortType: true
		},
	},
	{
		label: '最晚发货时间，从晚到早',
		value: 4,
		field: {
			sortBy: 'ecLastDeliveryTime',
			sortType: false
		},
	},
	{
		label: '单件在前',
		value: 5,
		field: {
			sortBy: 'goodsMulti',
			sortType: true
		},
	},
	{
		label: '多件在前',
		value: 6,
		field: {
			sortBy: 'goodsMulti',
			sortType: false
		},
	},
]

//右侧操作区
const RightAction = ({ initColumns, realColumns, setSortField, updatePageConfig }) => {

	//当前选择的数据
	const [orderType, setOrderType] = useState(2);

	//设置列信息
	const [visible, setVisible] = useState(null);

	//列设置props
	const EditColumnsProps = {
		initColumns,
		realColumns,
		updatePageConfig,
		handleCancel() {
			setVisible(null);
		},
		handleOk() {
			setVisible(null);
		},
	}

	const CombGoodsLogProps = {
		logType: 'updateLog',
		title: '修改日志',
		handleOk() {},
		onCancel() {
			// setAnalytic("");
			setVisible('')
		}
	};

	//基础设置参数
	const BasicSetProps = {
		handleCancel() {
			setVisible(null);
		},
		handleOk() {
			setVisible(null);
		},
	}

	return (
		<div style={{ float: 'right' }}>
			<SelectAction
				width="120px"
				style={{ display: 'inline-block', margin: '0 8px 8px 0' }}
				value={orderType}
				onChange={(value, option) => {
					setOrderType(option.value)
					setSortField(option.field)
				}}
				options={options}
			/>
			<Button type="text" onClick={() => setVisible('basicSet')}>
				<IconFont type="icona-lujing12" />
				基础功能设置
			</Button>
			<Button type="text" onClick={() => setVisible('editColumns')}>
				<IconFont type="icona-lujing12" />
				列表设置
			</Button>
			{visible == 'editColumns' && <EditColumns {...EditColumnsProps} />}
			{visible == 'basicSet' && <BasicSet { ...BasicSetProps } /> }
		</div>
	)
}

export default RightAction;